package service

import (
	"SE/model"
	"SE/repository"
	"time"
)

type CarService interface {
	//检查车辆是否在里面
	CarExist(carId, location string) bool
	// 添加新车
	CarIn(car model.CarP) error
	CarOut(id, pid int) (time.Time, error)
}

type carService struct {
	carRepo repository.CarRepository
}

func (c carService) CarOut(id, pid int) (time.Time, error) {
	//TODO implement me
	return c.carRepo.DeleteUser(id, pid)
}

func (c carService) CarExist(carId, location string) bool {
	return c.carRepo.UserExists(carId, location)
}

func (c carService) CarIn(car model.CarP) error {
	return c.carRepo.CreateUser(&car)
}

// NewCarService 构造函数，返回一个新的UserService实例
func NewCarService(carRepo repository.CarRepository) CarService {
	return &carService{carRepo: carRepo}
}
